﻿using System;
using System.Windows.Forms;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YRevitJig;

namespace YJKDimensionModel.DetailIndex.Jig
{
	internal class CircleJig : XCircleJig
	{
		public CircleJig(UIDocument uiDoc) : base(uiDoc)
		{
		}

		public new XYZ PickCenterPoint(string strPrompt = "请确定圆中心点:")
		{
			XYZ centerPoint;
			try
			{
				base.JigStage = XCircleJig.EStage.eCenterPt;
				base.CenterPoint = base.UiDoc.Selection.PickPoint(strPrompt);
				base.JigStage = XCircleJig.EStage.eNoOper;
				centerPoint = base.CenterPoint;
			}
			catch
			{
				base.CenterPoint = null;
				base.JigStage = XCircleJig.EStage.eNoOper;
				throw;
			}
			return centerPoint;
		}

		public double PickRadis(XYZ ptCenter, ref XYZ onCirclPoint, string strPrompt = "请确定圆上一点：")
		{
			try
			{
				base.JigStage = XCircleJig.EStage.eOnCurve;
				base.CenterPoint = ptCenter;
				onCirclPoint = base.UiDoc.Selection.PickPoint(strPrompt);
			}
			catch
			{
				if (this.m_prompDlg != null && base.CmdEndType == XUiJigBase.ECmdEndType.eEnter)
				{
					base.CmdEndType = XUiJigBase.ECmdEndType.eOther;
					XYZ xyz = base.Client2Revit(this.m_ptCur);
					string inputValue = this.m_prompDlg.GetInputValue();
					double num = Convert.ToDouble(inputValue) / 304.8;
					XYZ xyz2 = (xyz - base.CenterPoint).Normalize();
					base.OnCurvePoint = base.CenterPoint + xyz2 * num;
					throw;
				}
				base.OnCurvePoint = null;
				return 0.0;
			}
			base.JigStage = XCircleJig.EStage.eNoOper;
			return base.CenterPoint.DistanceTo(onCirclPoint);
		}

		public override void Draw(PaintEventArgs paintEventArgs)
		{
			base.Draw(paintEventArgs);
		}
	}
}
